
import uiautomator2 as u2
from adbutils import adb

# device_ip = 'e0edbd001403053'
# device_ip = '192.168.66.237:5555'
device_ip = '10.10.113.54:5555'
d = u2.connect(device_ip)
adb_device = adb.device(serial=device_ip)
# adb_device.root()

if __name__ == '__main__':
    adb_device.root()
    # adb_device.shell([r"sendevent /dev/input/event0 1 353 1", r"sendevent /dev/input/event0 0 0 0"])
    # adb_device.shell(r"sendevent /dev/input/event0 1 353 1")
    # res = adb_device.shell("< test.txt")
    # res = adb_device.shell("./data/test.sh")
    res = adb_device.shell(
        "su & sendevent /dev/input/event0 1 353 1 & sendevent /dev/input/event0 0 0 0 & echo 'down' & sleep 3 & sendevent /dev/input/event0 1 353 0 & sendevent /dev/input/event0 0 0 0 & echo 'up'")
    print(res)
